﻿<%@ Page Title="jQuery Treeview in ASP.NET WebForms - PageMethod (client-side workaround)" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="PageMethodClient.aspx.cs" Inherits="jQuery.Treeview.PageMethodClient" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <ul id="fileSystemInfos" class="filetree"></ul><br />
    <div id="fileSystemInfosControl">
        <a href="?#">Collapse All</a> | <a href="?#">Expand All</a>
    </div>
</asp:Content>
<asp:Content ID="ScriptContent" runat="server" ContentPlaceHolderID="ScriptContent">
    <script src="Scripts/jquery-treeview-async-0.1.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#fileSystemInfos').treeview({
                url: '<% = ResolveClientUrl("~/PageMethodClient.aspx/FileSystemInfos") %>',
                control: '#fileSystemInfosControl',
                ajax: {
                    contentType: 'application/json; charset=utf-8',
                    xhr: function () {
                        if (this.url.indexOf('=') >= 0) {
                            this.url = this.url.replace(/=/g, '="') + '"';
                        };
                        return $.ajaxSettings.xhr.call(this);
                    },
                    dataFilter: function (data, dataType) {
                        return $.parseJSON(data).d;
                    }
                }
            })
        });
    </script>
</asp:Content>
